home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume9 / uemacs3.8b / part04 < prev    next >
Encoding:
Internet Message Format  |  1987-03-12  |  47.6 KB

  1. Subject:  v09i036:  MicroEMACS, version 3.8b, Part04/14
  2. Newsgroups: mod.sources
  3. Approved: rs@mirror.TMC.COM
  4.  
  5. Submitted by: ihnp4!itivax!duncan!lawrence (Daniel Lawrence)
  6. Mod.sources: Volume 9, Issue 36
  7. Archive-name: uemacs3.8b/Part04
  8.  
  9. #! /bin/sh
  10. # This is a shell archive.  Remove anything before this line,
  11. # then unpack it by saving it in a file and typing "sh file".
  12. # If this archive is complete, you will see the message:
  13. #        "End of archive 4 (of 14)."
  14. # Contents:  ebind.h eval.c menu.cmd st520.c
  15. # Wrapped by rs@mirror on Fri Mar 13 13:23:45 1987
  16. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  17. echo shar: Extracting \"ebind.h\" \(11355 characters\)
  18. if test -f ebind.h ; then 
  19.   echo shar: Will not over-write existing file \"ebind.h\"
  20. else
  21. sed "s/^X//" >ebind.h <<'END_OF_ebind.h'
  22. X/*    EBIND:        Initial default key to function bindings for
  23. X            MicroEMACS 3.7
  24. X*/
  25. X
  26. X/*
  27. X * Command table.
  28. X * This table  is *roughly* in ASCII order, left to right across the
  29. X * characters of the command. This expains the funny location of the
  30. X * control-X commands.
  31. X */
  32. XKEYTAB  keytab[NBINDS] = {
  33. X    {CTRL|'A',        gotobol},
  34. X    {CTRL|'B',        backchar},
  35. X    {CTRL|'C',        insspace},
  36. X    {CTRL|'D',        forwdel},
  37. X    {CTRL|'E',        gotoeol},
  38. X    {CTRL|'F',        forwchar},
  39. X    {CTRL|'G',        ctrlg},
  40. X    {CTRL|'H',        backdel},
  41. X    {CTRL|'I',        tab},
  42. X    {CTRL|'J',        indent},
  43. X    {CTRL|'K',        killtext},
  44. X    {CTRL|'L',        refresh},
  45. X    {CTRL|'M',        newline},
  46. X    {CTRL|'N',        forwline},
  47. X    {CTRL|'O',        openline},
  48. X    {CTRL|'P',        backline},
  49. X    {CTRL|'Q',        quote},
  50. X    {CTRL|'R',        backsearch},
  51. X    {CTRL|'S',        forwsearch},
  52. X    {CTRL|'T',        twiddle},
  53. X    {CTRL|'U',        unarg},
  54. X    {CTRL|'V',        forwpage},
  55. X    {CTRL|'W',        killregion},
  56. X    {CTRL|'X',        cex},
  57. X    {CTRL|'Y',        yank},
  58. X    {CTRL|'Z',        backpage},
  59. X    {CTRL|']',        meta},
  60. X    {CTLX|CTRL|'B',        listbuffers},
  61. X    {CTLX|CTRL|'C',        quit},          /* Hard quit.           */
  62. X    {CTLX|CTRL|'F',        filefind},
  63. X    {CTLX|CTRL|'I',        insfile},
  64. X    {CTLX|CTRL|'L',        lowerregion},
  65. X    {CTLX|CTRL|'M',        delmode},
  66. X    {CTLX|CTRL|'N',        mvdnwind},
  67. X    {CTLX|CTRL|'O',        deblank},
  68. X    {CTLX|CTRL|'P',        mvupwind},
  69. X    {CTLX|CTRL|'R',        fileread},
  70. X    {CTLX|CTRL|'S',        filesave},
  71. X    {CTLX|CTRL|'U',        upperregion},
  72. X    {CTLX|CTRL|'V',        viewfile},
  73. X    {CTLX|CTRL|'W',        filewrite},
  74. X    {CTLX|CTRL|'X',        swapmark},
  75. X    {CTLX|CTRL|'Z',        shrinkwind},
  76. X    {CTLX|'?',        deskey},
  77. X    {CTLX|'!',        spawn},
  78. X    {CTLX|'@',        pipe},
  79. X    {CTLX|'#',        filter},
  80. X    {CTLX|'=',        showcpos},
  81. X    {CTLX|'(',        ctlxlp},
  82. X    {CTLX|')',        ctlxrp},
  83. X    {CTLX|'^',        enlargewind},
  84. X    {CTLX|'0',        delwind},
  85. X    {CTLX|'1',        onlywind},
  86. X    {CTLX|'2',        splitwind},
  87. X    {CTLX|'A',        setvar},
  88. X    {CTLX|'B',        usebuffer},
  89. X    {CTLX|'C',        spawncli},
  90. X#if    BSD
  91. X    {CTLX|'D',        bktoshell},
  92. X#endif
  93. X    {CTLX|'E',        ctlxe},
  94. X    {CTLX|'F',        setfillcol},
  95. X    {CTLX|'K',        killbuffer},
  96. X    {CTLX|'M',        setmode},
  97. X    {CTLX|'N',        filename},
  98. X    {CTLX|'O',        nextwind},
  99. X    {CTLX|'P',        prevwind},
  100. X#if    ISRCH
  101. X    {CTLX|'R',        risearch},
  102. X    {CTLX|'S',        fisearch},
  103. X#endif
  104. X    {CTLX|'W',        resize},
  105. X    {CTLX|'X',        nextbuffer},
  106. X    {CTLX|'Z',        enlargewind},
  107. X#if    WORDPRO
  108. X    {META|CTRL|'C',        wordcount},
  109. X#endif
  110. X#if    CFENCE
  111. X    {META|CTRL|'F',        getfence},
  112. X#endif
  113. X    {META|CTRL|'H',        delbword},
  114. X    {META|CTRL|'K',        unbindkey},
  115. X    {META|CTRL|'L',        reposition},
  116. X    {META|CTRL|'M',        delgmode},
  117. X    {META|CTRL|'N',        namebuffer},
  118. X    {META|CTRL|'R',        qreplace},
  119. X    {META|CTRL|'S',        newsize},
  120. X    {META|CTRL|'T',        newwidth},
  121. X    {META|CTRL|'V',        scrnextdw},
  122. X#if    WORDPRO
  123. X    {META|CTRL|'W',        killpara},
  124. X#endif
  125. X    {META|CTRL|'Z',        scrnextup},
  126. X    {META|' ',        setmark},
  127. X    {META|'?',        help},
  128. X    {META|'!',        reposition},
  129. X    {META|'.',        setmark},
  130. X    {META|'>',        gotoeob},
  131. X    {META|'<',        gotobob},
  132. X    {META|'~',        unmark},
  133. X#if    APROP
  134. X    {META|'A',        apro},
  135. X#endif
  136. X    {META|'B',        backword},
  137. X    {META|'C',        capword},
  138. X    {META|'D',        delfword},
  139. X#if    CRYPT
  140. X    {META|'E',        setkey},
  141. X#endif
  142. X    {META|'F',        forwword},
  143. X    {META|'G',        gotoline},
  144. X    {META|'K',        bindtokey},
  145. X    {META|'L',        lowerword},
  146. X    {META|'M',        setgmode},
  147. X#if    WORDPRO
  148. X    {META|'N',        gotoeop},
  149. X    {META|'P',        gotobop},
  150. X    {META|'Q',        fillpara},
  151. X#endif
  152. X    {META|'R',        sreplace},
  153. X#if    BSD
  154. X    {META|'S',        bktoshell},
  155. X#endif
  156. X    {META|'U',        upperword},
  157. X    {META|'V',        backpage},
  158. X    {META|'W',        copyregion},
  159. X    {META|'X',        namedcmd},
  160. X    {META|'Z',        quickexit},
  161. X    {META|0x7F,              delbword},
  162. X
  163. X#if    MSDOS & (HP150 == 0) & (WANGPC == 0) & (HP110 == 0)
  164. X    {SPEC|CTRL|'_',        forwhunt},
  165. X    {SPEC|CTRL|'S',        backhunt},
  166. X    {SPEC|71,        gotobob},
  167. X    {SPEC|72,        backline},
  168. X    {SPEC|73,        backpage},
  169. X    {SPEC|75,        backchar},
  170. X    {SPEC|77,        forwchar},
  171. X    {SPEC|79,        gotoeob},
  172. X    {SPEC|80,        forwline},
  173. X    {SPEC|81,        forwpage},
  174. X    {SPEC|82,        insspace},
  175. X    {SPEC|83,        forwdel},
  176. X    {SPEC|115,        backword},
  177. X    {SPEC|116,        forwword},
  178. X#if    WORDPRO
  179. X    {SPEC|132,        gotobop},
  180. X    {SPEC|118,        gotoeop},
  181. X#endif
  182. X    {SPEC|84,        cbuf1},
  183. X    {SPEC|85,        cbuf2},
  184. X    {SPEC|86,        cbuf3},
  185. X    {SPEC|87,        cbuf4},
  186. X    {SPEC|88,        cbuf5},
  187. X    {SPEC|89,        cbuf6},
  188. X    {SPEC|90,        cbuf7},
  189. X    {SPEC|91,        cbuf8},
  190. X    {SPEC|92,        cbuf9},
  191. X    {SPEC|93,        cbuf10},
  192. X#endif
  193. X
  194. X#if    HP150
  195. X    {SPEC|32,        backline},
  196. X    {SPEC|33,        forwline},
  197. X    {SPEC|35,        backchar},
  198. X    {SPEC|34,        forwchar},
  199. X    {SPEC|44,        gotobob},
  200. X    {SPEC|46,        forwpage},
  201. X    {SPEC|47,        backpage},
  202. X    {SPEC|82,        nextwind},
  203. X    {SPEC|68,        openline},
  204. X    {SPEC|69,        killtext},
  205. X    {SPEC|65,        forwdel},
  206. X    {SPEC|64,        ctlxe},
  207. X    {SPEC|67,        refresh},
  208. X    {SPEC|66,        reposition},
  209. X    {SPEC|83,        help},
  210. X    {SPEC|81,        deskey},
  211. X#endif
  212. X
  213. X#if    HP110
  214. X    {SPEC|0x4b,        backchar},
  215. X    {SPEC|0x4d,        forwchar},
  216. X    {SPEC|0x48,        backline},
  217. X    {SPEC|0x50,        forwline},
  218. X    {SPEC|0x43,        help},
  219. X    {SPEC|0x73,        backword},
  220. X    {SPEC|0x74,        forwword},
  221. X    {SPEC|0x49,        backpage},
  222. X    {SPEC|0x51,        forwpage},
  223. X    {SPEC|84,        cbuf1},
  224. X    {SPEC|85,        cbuf2},
  225. X    {SPEC|86,        cbuf3},
  226. X    {SPEC|87,        cbuf4},
  227. X    {SPEC|88,        cbuf5},
  228. X    {SPEC|89,        cbuf6},
  229. X    {SPEC|90,        cbuf7},
  230. X    {SPEC|91,        cbuf8},
  231. X#endif
  232. X
  233. X#if    AMIGA
  234. X    {SPEC|'?',        help},
  235. X    {SPEC|'A',        backline},
  236. X    {SPEC|'B',        forwline},
  237. X    {SPEC|'C',        forwchar},
  238. X    {SPEC|'D',        backchar},
  239. X    {SPEC|'T',        backpage},
  240. X    {SPEC|'S',        forwpage},
  241. X    {SPEC|'a',        backword},
  242. X    {SPEC|'`',        forwword},
  243. X    {SPEC|'P',        cbuf1},
  244. X    {SPEC|'Q',        cbuf2},
  245. X    {SPEC|'R',        cbuf3},
  246. X    {SPEC|'S',        cbuf4},
  247. X    {SPEC|'T',        cbuf5},
  248. X    {SPEC|'U',        cbuf6},
  249. X    {SPEC|'V',        cbuf7},
  250. X    {SPEC|'W',        cbuf8},
  251. X    {SPEC|'X',        cbuf9},
  252. X    {SPEC|'Y',        cbuf10},
  253. X
  254. X#endif
  255. X
  256. X#if    ST520
  257. X    {SPEC|'?',        help},
  258. X    {SPEC|'A',        backline},
  259. X    {SPEC|'B',        forwline},
  260. X    {SPEC|'C',        forwchar},
  261. X    {SPEC|'D',        backchar},
  262. X    {SPEC|'T',        backpage},
  263. X    {SPEC|'S',        forwpage},
  264. X    {SPEC|'a',        backword},
  265. X    {SPEC|'`',        forwword},
  266. X    {SPEC|'P',        cbuf1},
  267. X    {SPEC|'Q',        cbuf2},
  268. X    {SPEC|'R',        cbuf3},
  269. X    {SPEC|'S',        cbuf4},
  270. X    {SPEC|'T',        cbuf5},
  271. X    {SPEC|'U',        cbuf6},
  272. X    {SPEC|'V',        cbuf7},
  273. X    {SPEC|'W',        cbuf8},
  274. X    {SPEC|'X',        cbuf9},
  275. X    {SPEC|'Y',        cbuf10},
  276. X
  277. X#endif
  278. X
  279. X#if  WANGPC
  280. X    SPEC|0xE0,              quit,           /* Cancel */
  281. X    SPEC|0xE1,              help,           /* Help */
  282. X    SPEC|0xF1,              help,           /* ^Help */
  283. X    SPEC|0xE3,              ctrlg,          /* Print */
  284. X    SPEC|0xF3,              ctrlg,          /* ^Print */
  285. X    SPEC|0xC0,              backline,       /* North */
  286. X    SPEC|0xD0,              gotobob,        /* ^North */
  287. X    SPEC|0xC1,              forwchar,       /* East */
  288. X    SPEC|0xD1,              gotoeol,        /* ^East */
  289. X    SPEC|0xC2,              forwline,       /* South */
  290. X    SPEC|0xD2,              gotobop,        /* ^South */
  291. X    SPEC|0xC3,              backchar,       /* West */
  292. X    SPEC|0xD3,              gotobol,        /* ^West */
  293. X    SPEC|0xC4,              ctrlg,          /* Home */
  294. X    SPEC|0xD4,              gotobob,        /* ^Home */
  295. X    SPEC|0xC5,              filesave,       /* Execute */
  296. X    SPEC|0xD5,              ctrlg,          /* ^Execute */
  297. X    SPEC|0xC6,              insfile,        /* Insert */
  298. X    SPEC|0xD6,              ctrlg,          /* ^Insert */
  299. X    SPEC|0xC7,              forwdel,        /* Delete */
  300. X    SPEC|0xD7,              killregion,     /* ^Delete */
  301. X    SPEC|0xC8,              backpage,       /* Previous */
  302. X    SPEC|0xD8,              prevwind,       /* ^Previous */
  303. X    SPEC|0xC9,              forwpage,       /* Next */
  304. X    SPEC|0xD9,              nextwind,       /* ^Next */
  305. X    SPEC|0xCB,              ctrlg,          /* Erase */
  306. X    SPEC|0xDB,              ctrlg,          /* ^Erase */
  307. X    SPEC|0xDC,              ctrlg,          /* ^Tab */
  308. X    SPEC|0xCD,              ctrlg,          /* BackTab */
  309. X    SPEC|0xDD,              ctrlg,          /* ^BackTab */
  310. X    SPEC|0x80,              ctrlg,          /* Indent */
  311. X    SPEC|0x90,              ctrlg,          /* ^Indent */
  312. X    SPEC|0x81,              ctrlg,          /* Page */
  313. X    SPEC|0x91,              ctrlg,          /* ^Page */
  314. X    SPEC|0x82,              ctrlg,          /* Center */
  315. X    SPEC|0x92,              ctrlg,          /* ^Center */
  316. X    SPEC|0x83,              ctrlg,          /* DecTab */
  317. X    SPEC|0x93,              ctrlg,          /* ^DecTab */
  318. X    SPEC|0x84,              ctrlg,          /* Format */
  319. X    SPEC|0x94,              ctrlg,          /* ^Format */
  320. X    SPEC|0x85,              ctrlg,          /* Merge */
  321. X    SPEC|0x95,              ctrlg,          /* ^Merge */
  322. X    SPEC|0x86,              setmark,        /* Note */
  323. X    SPEC|0x96,              ctrlg,          /* ^Note */
  324. X    SPEC|0x87,              ctrlg,          /* Stop */
  325. X    SPEC|0x97,              ctrlg,          /* ^Stop */
  326. X    SPEC|0x88,              forwsearch,     /* Srch */
  327. X    SPEC|0x98,              backsearch,     /* ^Srch */
  328. X    SPEC|0x89,              sreplace,       /* Replac */
  329. X    SPEC|0x99,              qreplace,       /* ^Replac */
  330. X    SPEC|0x8A,              ctrlg,          /* Copy */
  331. X    SPEC|0x9A,              ctrlg,          /* ^Copy */
  332. X    SPEC|0x8B,              ctrlg,          /* Move */
  333. X    SPEC|0x9B,              ctrlg,          /* ^Move */
  334. X    SPEC|0x8C,              namedcmd,       /* Command */
  335. X    SPEC|0x9C,              spawn,          /* ^Command */
  336. X    SPEC|0x8D,              ctrlg,          /* ^ */
  337. X    SPEC|0x9D,              ctrlg,          /* ^^ */
  338. X    SPEC|0x8E,              ctrlg,          /* Blank */
  339. X    SPEC|0x9E,              ctrlg,          /* ^Blank */
  340. X    SPEC|0x8F,              gotoline,       /* GoTo */
  341. X    SPEC|0x9F,              usebuffer,      /* ^GoTo */
  342. X#endif
  343. X    {0x7F,            backdel},
  344. X
  345. X    /* special internal bindings */
  346. X    SPEC|META|'W',        wrapword,    /* called on word wrap */
  347. X
  348. X    {0,            NULL}
  349. X};
  350. X
  351. X#if RAINBOW
  352. X
  353. X#include "rainbow.h"
  354. X
  355. X/*
  356. X * Mapping table from the LK201 function keys to the internal EMACS character.
  357. X */
  358. X
  359. Xshort lk_map[][2] = {
  360. X    Up_Key,                         CTRL+'P',
  361. X    Down_Key,                       CTRL+'N',
  362. X    Left_Key,                       CTRL+'B',
  363. X    Right_Key,                      CTRL+'F',
  364. X    Shift+Left_Key,                 META+'B',
  365. X    Shift+Right_Key,                META+'F',
  366. X    Control+Left_Key,               CTRL+'A',
  367. X    Control+Right_Key,              CTRL+'E',
  368. X    Prev_Scr_Key,                   META+'V',
  369. X    Next_Scr_Key,                   CTRL+'V',
  370. X    Shift+Up_Key,                   META+'<',
  371. X    Shift+Down_Key,                 META+'>',
  372. X    Cancel_Key,                     CTRL+'G',
  373. X    Find_Key,                       CTRL+'S',
  374. X    Shift+Find_Key,                 CTRL+'R',
  375. X    Insert_Key,                     CTRL+'Y',
  376. X    Options_Key,                    CTRL+'D',
  377. X    Shift+Options_Key,              META+'D',
  378. X    Remove_Key,                     CTRL+'W',
  379. X    Shift+Remove_Key,               META+'W',
  380. X    Select_Key,                     CTRL+'@',
  381. X    Shift+Select_Key,               CTLX+CTRL+'X',
  382. X    Interrupt_Key,                  CTRL+'U',
  383. X    Keypad_PF2,                     META+'L',
  384. X    Keypad_PF3,                     META+'C',
  385. X    Keypad_PF4,                     META+'U',
  386. X    Shift+Keypad_PF2,               CTLX+CTRL+'L',
  387. X    Shift+Keypad_PF4,               CTLX+CTRL+'U',
  388. X    Keypad_1,                       CTLX+'1',
  389. X    Keypad_2,                       CTLX+'2',
  390. X    Do_Key,                         CTLX+'E',
  391. X    Keypad_4,                       CTLX+CTRL+'B',
  392. X    Keypad_5,                       CTLX+'B',
  393. X    Keypad_6,                       CTLX+'K',
  394. X    Resume_Key,                     META+'!',
  395. X    Control+Next_Scr_Key,           CTLX+'N',
  396. X    Control+Prev_Scr_Key,           CTLX+'P',
  397. X    Control+Up_Key,                 CTLX+CTRL+'P',
  398. X    Control+Down_Key,               CTLX+CTRL+'N',
  399. X    Help_Key,                       CTLX+'=',
  400. X    Shift+Do_Key,                   CTLX+'(',
  401. X    Control+Do_Key,                 CTLX+')',
  402. X    Keypad_0,                       CTLX+'Z',
  403. X    Shift+Keypad_0,                 CTLX+CTRL+'Z',
  404. X    Main_Scr_Key,                   CTRL+'C',
  405. X    Keypad_Enter,                   CTLX+'!',
  406. X    Exit_Key,                       CTLX+CTRL+'C',
  407. X    Shift+Exit_Key,                 CTRL+'Z'
  408. X};
  409. X
  410. X#define lk_map_size     (sizeof(lk_map)/2)
  411. X#endif
  412. X
  413. END_OF_ebind.h
  414. if test 11355 -ne `wc -c <ebind.h`; then
  415.     echo shar: \"ebind.h\" unpacked with wrong size!
  416. fi
  417. # end of overwriting check
  418. fi
  419. echo shar: Extracting \"eval.c\" \(10700 characters\)
  420. if test -f eval.c ; then 
  421.   echo shar: Will not over-write existing file \"eval.c\"
  422. else
  423. sed "s/^X//" >eval.c <<'END_OF_eval.c'
  424. X/*    EVAL.C:    Expresion evaluation functions for
  425. X        MicroEMACS
  426. X
  427. X    written 1986 by Daniel Lawrence                */
  428. X
  429. X#include    <stdio.h>
  430. X#include    "estruct.h"
  431. X#include    "edef.h"
  432. X#include    "evar.h"
  433. X
  434. X#if    MEGAMAX & ST520
  435. Xoverlay    "eval"
  436. X#endif
  437. X
  438. Xchar value[80];        /* buffer to return value in */
  439. X
  440. Xvarinit()        /* initialize the user variable list */
  441. X
  442. X{
  443. X    register int i;
  444. X
  445. X    for (i=0; i < MAXVARS; i++)
  446. X        uv[i].u_name[0] = 0;
  447. X}
  448. X
  449. Xchar *gtfun(fname)    /* evaluate a function */
  450. X
  451. Xchar *fname;        /* name of function to evaluate */
  452. X
  453. X{
  454. X    register int fnum;        /* index to function to eval */
  455. X    register int status;        /* return status */
  456. X    char arg1[NSTRING];        /* value of first argument */
  457. X    char arg2[NSTRING];        /* value of second argument */
  458. X    char arg3[NSTRING];        /* value of third argument */
  459. X    static char result[2 * NSTRING];    /* string result */
  460. X
  461. X    /* look the function up in the function table */
  462. X    fname[3] = 0;    /* only first 3 chars significant */
  463. X    for (fnum = 0; fnum < NFUNCS; fnum++)
  464. X        if (strcmp(fname, funcs[fnum].f_name) == 0)
  465. X            break;
  466. X
  467. X    /* return errorm on a bad reference */
  468. X    if (fnum == NFUNCS)
  469. X        return(errorm);
  470. X
  471. X    /* retrieve the first argument */
  472. X    if ((status = macarg(arg1)) != TRUE)
  473. X        return(errorm);
  474. X
  475. X    /* if needed, retrieve the second argument */
  476. X    if (funcs[fnum].f_type >= DYNAMIC) {
  477. X        if ((status = macarg(arg2)) != TRUE)
  478. X            return(errorm);
  479. X
  480. X        /* if needed, retrieve the third argument */
  481. X        if (funcs[fnum].f_type >= TRINAMIC)
  482. X            if ((status = macarg(arg3)) != TRUE)
  483. X                return(errorm);
  484. X    }
  485. X
  486. X    /* and now evaluate it! */
  487. X    switch (fnum) {
  488. X        case UFADD:    return(itoa(atoi(arg1) + atoi(arg2)));
  489. X        case UFSUB:    return(itoa(atoi(arg1) - atoi(arg2)));
  490. X        case UFTIMES:    return(itoa(atoi(arg1) * atoi(arg2)));
  491. X        case UFDIV:    return(itoa(atoi(arg1) / atoi(arg2)));
  492. X        case UFMOD:    return(itoa(atoi(arg1) % atoi(arg2)));
  493. X        case UFNEG:    return(itoa(-atoi(arg1)));
  494. X        case UFCAT:    strcpy(result, arg1);
  495. X                return(strcat(result, arg2));
  496. X        case UFLEFT:    return(strncpy(result, arg1, atoi(arg2)));
  497. X        case UFRIGHT:    return(strcpy(result, &arg1[atoi(arg2)-1]));
  498. X        case UFMID:    return(strncpy(result, &arg1[atoi(arg2)-1],
  499. X                    atoi(arg3)));
  500. X        case UFNOT:    return(ltos(stol(arg1) == FALSE));
  501. X        case UFEQUAL:    return(ltos(atoi(arg1) == atoi(arg2)));
  502. X        case UFLESS:    return(ltos(atoi(arg1) < atoi(arg2)));
  503. X        case UFGREATER:    return(ltos(atoi(arg1) > atoi(arg2)));
  504. X        case UFSEQUAL:    return(ltos(strcmp(arg1, arg2) == 0));
  505. X        case UFSLESS:    return(ltos(strcmp(arg1, arg2) < 0));
  506. X        case UFSGREAT:    return(ltos(strcmp(arg1, arg2) > 0));
  507. X        case UFIND:    return(getval(arg1));
  508. X    }
  509. X
  510. X    exit(-11);    /* never should get here */
  511. X}
  512. X
  513. Xchar *gtusr(vname)    /* look up a user var's value */
  514. X
  515. Xchar *vname;        /* name of user variable to fetch */
  516. X
  517. X{
  518. X
  519. X    register int vnum;    /* ordinal number of user var */
  520. X
  521. X    /* scan the list looking for the user var name */
  522. X    for (vnum = 0; vnum < MAXVARS; vnum++)
  523. X        if (strcmp(vname, uv[vnum].u_name) == 0)
  524. X            break;
  525. X
  526. X    /* return errorm on a bad reference */
  527. X    if (vnum == MAXVARS)
  528. X        return(errorm);
  529. X
  530. X    return(uv[vnum].u_value);
  531. X}
  532. X
  533. Xchar *gtenv(vname)
  534. X
  535. Xchar *vname;        /* name of environment variable to retrieve */
  536. X
  537. X{
  538. X    register int vnum;    /* ordinal number of var refrenced */
  539. X
  540. X    /* scan the list, looking for the referenced name */
  541. X    for (vnum = 0; vnum < NEVARS; vnum++)
  542. X        if (strcmp(vname, envars[vnum]) == 0)
  543. X            break;
  544. X
  545. X    /* return errorm on a bad reference */
  546. X    if (vnum == NEVARS)
  547. X        return(errorm);
  548. X
  549. X    /* otherwise, fetch the appropriate value */
  550. X    switch (vnum) {
  551. X        case EVFILLCOL:    return(itoa(fillcol));
  552. X        case EVPAGELEN:    return(itoa(term.t_nrow + 1));
  553. X        case EVCURCOL:    return(itoa(getccol(FALSE)));
  554. X        case EVCURLINE: return(itoa(getcline()));
  555. X        case EVRAM:    return(itoa((int)(envram / 1024l)));
  556. X        case EVFLICKER:    return(ltos(flickcode));
  557. X        case EVCURWIDTH:return(itoa(term.t_nrow));
  558. X        case EVCBUFNAME:return(curbp->b_bname);
  559. X        case EVCFNAME:    return(curbp->b_fname);
  560. X        case EVSRES:    return(sres);
  561. X        case EVDEBUG:    return(ltos(macbug));
  562. X        case EVSTATUS:    return(ltos(cmdstatus));
  563. X    }
  564. X}
  565. X
  566. Xint setvar(f, n)        /* set a variable */
  567. X
  568. Xint f;        /* default flag */
  569. Xint n;        /* numeric arg (can overide prompted value) */
  570. X
  571. X{
  572. X    register int vnum;    /* ordinal number of var refrenced */
  573. X    register int status;    /* status return */
  574. X    register int vtype;    /* type of variable to set */
  575. X    register char * sp;    /* scratch string pointer */
  576. X    char var[NVSIZE+1];    /* name of variable to fetch */
  577. X    char value[NSTRING];    /* value to set variable to */
  578. X
  579. X    /* first get the variable to set.. */
  580. X    if (clexec == FALSE) {
  581. X        status = mlreply("Variable to set: ", &var[0], NVSIZE);
  582. X        if (status != TRUE)
  583. X            return(status);
  584. X    } else {    /* macro line argument */
  585. X        /* grab token and skip it */
  586. X        execstr = token(execstr, var);
  587. X    }
  588. X
  589. X    /* check the legality and find the var */
  590. Xsv01:    vtype = -1;
  591. X    switch (var[0]) {
  592. X
  593. X        case '$': /* check for legal enviromnent var */
  594. X            for (vnum = 0; vnum < NEVARS; vnum++)
  595. X                if (strcmp(&var[1], envars[vnum]) == 0) {
  596. X                    vtype = TKENV;
  597. X                    break;
  598. X                }
  599. X            break;
  600. X
  601. X        case '%': /* check for existing legal user variable */
  602. X            for (vnum = 0; vnum < MAXVARS; vnum++)
  603. X                if (strcmp(&var[1], uv[vnum].u_name) == 0) {
  604. X                    vtype = TKVAR;
  605. X                    break;
  606. X                }
  607. X            if (vnum < MAXVARS)
  608. X                break;
  609. X
  610. X            /* create a new one??? */
  611. X            for (vnum = 0; vnum < MAXVARS; vnum++)
  612. X                if (uv[vnum].u_name[0] == 0) {
  613. X                    vtype = TKVAR;
  614. X                    strcpy(uv[vnum].u_name, &var[1]);
  615. X                    break;
  616. X                }
  617. X            break;
  618. X
  619. X        case '&':    /* indirect operator? */
  620. X            var[4] = 0;
  621. X            if (strcmp(&var[1], "ind") == 0) {
  622. X                /* grab token, and eval it */
  623. X                execstr = token(execstr, var);
  624. X                strcpy(var, getval(var));
  625. X                goto sv01;
  626. X            }
  627. X    }
  628. X
  629. X    /* if its not legal....bitch */
  630. X    if (vtype == -1) {
  631. X        mlwrite("%%No such variable");
  632. X        return(FALSE);
  633. X    }
  634. X
  635. X    /* get the value for that variable */
  636. X    if (f == TRUE)
  637. X        strcpy(value, itoa(n));
  638. X    else {
  639. X        status = mlreply("Value: ", &value[0], NSTRING);
  640. X        if (status != TRUE)
  641. X            return(status);
  642. X    }
  643. X
  644. X    /* and set the appropriate value */
  645. X    status = TRUE;
  646. X    switch (vtype) {
  647. X    case TKVAR: /* set a user variable */
  648. X        if (uv[vnum].u_value != NULL)
  649. X            free(uv[vnum].u_value);
  650. X        sp = malloc(strlen(value) + 1);
  651. X        if (sp == NULL)
  652. X            return(FALSE);
  653. X        strcpy(sp, value);
  654. X        uv[vnum].u_value = sp;
  655. X        break;
  656. X
  657. X    case TKENV: /* set an environment variable */
  658. X        status = TRUE;    /* by default */
  659. X        switch (vnum) {
  660. X        case EVFILLCOL:    fillcol = atoi(value);
  661. X                break;
  662. X        case EVPAGELEN:    status = newsize(TRUE, atoi(value));
  663. X                break;
  664. X        case EVCURCOL:    status = setccol(atoi(value));
  665. X                break;
  666. X        case EVCURLINE:    status = gotoline(TRUE, atoi(value));
  667. X                break;
  668. X        case EVRAM:    break;
  669. X        case EVFLICKER:    flickcode = stol(value);
  670. X                break;
  671. X        case EVCURWIDTH:status = newwidth(TRUE, atoi(value));
  672. X                break;
  673. X        case EVCBUFNAME:strcpy(curbp->b_bname, value);
  674. X                curwp->w_flag |= WFMODE;
  675. X                break;
  676. X        case EVCFNAME:    strcpy(curbp->b_fname, value);
  677. X                curwp->w_flag |= WFMODE;
  678. X                break;
  679. X        case EVSRES:    status = TTrez(value);
  680. X                break;
  681. X        case EVDEBUG:    macbug = stol(value);
  682. X                break;
  683. X        case EVSTATUS:    cmdstatus = stol(value);
  684. X                break;
  685. X        }
  686. X        break;
  687. X    }
  688. X    return(status);
  689. X}
  690. X
  691. X/*    atoi:    ascii string to integer......This is too
  692. X        inconsistant to use the system's    */
  693. X
  694. Xatoi(st)
  695. X
  696. Xchar *st;
  697. X
  698. X{
  699. X    int result;    /* resulting number */
  700. X    int sign;    /* sign of resulting number */
  701. X    char c;        /* current char being examined */
  702. X
  703. X    result = 0;
  704. X    sign = 1;
  705. X    while ((c = *st++)) {
  706. X        if (c == '-')
  707. X            sign *= -1;
  708. X        if (c >= '0' && c <= '9')
  709. X            result = result * 10 + c - '0';
  710. X    }
  711. X
  712. X    return(result * sign);
  713. X}
  714. X
  715. X/*    itoa:    integer to ascii string.......... This is too
  716. X        inconsistant to use the system's    */
  717. X
  718. Xchar *itoa(i)
  719. X
  720. Xint i;    /* integer to translate to a string */
  721. X
  722. X{
  723. X    register int digit;        /* current digit being used */
  724. X    register char *sp;        /* pointer into result */
  725. X    register int sign;        /* sign of resulting number */
  726. X    static char result[INTWIDTH+1];    /* resulting string */
  727. X
  728. X    /* eliminate the trivial 0 */
  729. X    if (i == 0)
  730. X        return("0");
  731. X
  732. X    /* record the sign...*/
  733. X    sign = 1;
  734. X    if (i < 0) {
  735. X        sign = -1;
  736. X        i = -i;
  737. X    }
  738. X
  739. X    /* and build the string (backwards!) */
  740. X    sp = result + INTWIDTH;
  741. X    *sp = 0;
  742. X    while (i) {
  743. X        digit = i % 10;
  744. X        *(--sp) = '0' + digit;    /* and install the new digit */
  745. X        i = i / 10;
  746. X    }
  747. X
  748. X    /* and fix the sign */
  749. X    if (sign == -1) {
  750. X        *(--sp) = '-';    /* and install the minus sign */
  751. X    }
  752. X
  753. X    return(sp);
  754. X}
  755. X
  756. Xint gettyp(token)    /* find the type of a passed token */
  757. X
  758. Xchar *token;    /* token to analyze */
  759. X
  760. X{
  761. X    register char c;    /* first char in token */
  762. X
  763. X    /* grab the first char (this is all we need) */
  764. X    c = *token;
  765. X
  766. X    /* no blanks!!! */
  767. X    if (c == 0)
  768. X        return(TKNUL);
  769. X
  770. X    /* a numeric literal? */
  771. X    if (c >= '0' && c <= '9')
  772. X        return(TKLIT);
  773. X
  774. X    switch (c) {
  775. X        case '"':    return(TKSTR);
  776. X
  777. X        case '!':    return(TKDIR);
  778. X        case '@':    return(TKARG);
  779. X        case '#':    return(TKBUF);
  780. X        case '$':    return(TKENV);
  781. X        case '%':    return(TKVAR);
  782. X        case '&':    return(TKFUN);
  783. X        case '*':    return(TKLBL);
  784. X
  785. X        default:    return(TKCMD);
  786. X    }
  787. X}
  788. X
  789. Xchar *getval(token)    /* find the value of a token */
  790. X
  791. Xchar *token;        /* token to evaluate */
  792. X
  793. X{
  794. X    register int status;    /* error return */
  795. X    register BUFFER *bp;    /* temp buffer pointer */
  796. X    register int blen;    /* length of buffer argument */
  797. X    char buf[NSTRING];    /* string buffer for some returns */
  798. X
  799. X    switch (gettyp(token)) {
  800. X        case TKNUL:    return("");
  801. X
  802. X        case TKARG:    /* interactive argument */
  803. X                status = getstring(getval(&token[1]),
  804. X                       buf, NSTRING, ctoec('\n'));
  805. X                if (status == ABORT)
  806. X                    return(errorm);
  807. X                return(buf);
  808. X
  809. X        case TKBUF:    /* buffer contents fetch */
  810. X
  811. X                /* grab the right buffer */
  812. X                bp = bfind(getval(&token[1]), FALSE, 0);
  813. X                if (bp == NULL)
  814. X                    return(errorm);
  815. X        
  816. X                /* make sure we are not at the end */
  817. X                if (bp->b_linep == bp->b_dotp)
  818. X                    return(errorm);
  819. X        
  820. X                /* grab the line as an argument */
  821. X                blen = bp->b_dotp->l_used;
  822. X                if (blen > NSTRING)
  823. X                    blen = NSTRING;
  824. X                strncpy(buf, bp->b_dotp->l_text, blen);
  825. X                buf[blen] = 0;
  826. X        
  827. X                /* and step the buffer's line ptr ahead a line */
  828. X                bp->b_dotp = bp->b_dotp->l_fp;
  829. X                bp->b_doto = 0;
  830. X
  831. X                /* and return the spoils */
  832. X                return(buf);        
  833. X
  834. X        case TKVAR:    return(gtusr(token+1));
  835. X        case TKENV:    return(gtenv(token+1));
  836. X        case TKFUN:    return(gtfun(token+1));
  837. X        case TKDIR:    return(errorm);
  838. X        case TKLBL:    return(itoa(gtlbl(token)));
  839. X        case TKLIT:    return(token);
  840. X        case TKSTR:    return(token+1);
  841. X        case TKCMD:    return(token);
  842. X    }
  843. X}
  844. X
  845. Xgtlbl(token)    /* find the line number of the given label */
  846. X
  847. Xchar *token;    /* label name to find */
  848. X
  849. X{
  850. X    return(1);
  851. X}
  852. X
  853. Xint stol(val)    /* convert a string to a numeric logical */
  854. X
  855. Xchar *val;    /* value to check for stol */
  856. X
  857. X{
  858. X    /* check for logical values */
  859. X    if (val[0] == 'F')
  860. X        return(FALSE);
  861. X    if (val[0] == 'T')
  862. X        return(TRUE);
  863. X
  864. X    /* check for numeric truth (!= 0) */
  865. X    return((atoi(val) != 0));
  866. X}
  867. X
  868. Xchar *ltos(val)        /* numeric logical to string logical */
  869. X
  870. Xint val;    /* value to translate */
  871. X
  872. X{
  873. X    if (val)
  874. X        return(truem);
  875. X    else
  876. X        return(falsem);
  877. X}
  878. END_OF_eval.c
  879. if test 10700 -ne `wc -c <eval.c`; then
  880.     echo shar: \"eval.c\" unpacked with wrong size!
  881. fi
  882. # end of overwriting check
  883. fi
  884. echo shar: Extracting \"menu.cmd\" \(11966 characters\)
  885. if test -f menu.cmd ; then 
  886.   echo shar: Will not over-write existing file \"menu.cmd\"
  887. else
  888. sed "s/^X//" >menu.cmd <<'END_OF_menu.cmd'
  889. X;    MENU.CMD:    Menu learning system for MicroEMACS 3.7
  890. X;
  891. X;            This file is executed to activate MicroEMACS's
  892. X;            menu interface code
  893. X
  894. X;    setup windows for use
  895. X
  896. X    add-global-mode "blue"
  897. X    1 split-current-window
  898. X    5 resize-window
  899. X    add-mode "red"
  900. X    view-file "menu1"
  901. X    name-buffer "menu window"
  902. X    change-file-name ""
  903. X    add-mode "view"
  904. X    next-window
  905. X
  906. X;    Load menu routines as needed
  907. X
  908. X;    Activate Main Menu
  909. X
  910. X1    store-macro
  911. X    save-window
  912. X    1 next-window
  913. X    beginning-of-file
  914. X    search-forward "<<01"
  915. X    next-line
  916. X    1 redraw-display
  917. X    restore-window
  918. X    update-screen
  919. X
  920. X;    ***** Rebind the Function key group
  921. X
  922. X    bind-to-key execute-macro-3    FN;
  923. X    bind-to-key execute-macro-4    FN<
  924. X    bind-to-key execute-macro-5    FN=
  925. X    bind-to-key execute-macro-6    FN>
  926. X    bind-to-key execute-macro-7    FN?
  927. X    bind-to-key execute-macro-8    FN@
  928. X    bind-to-key execute-macro-9    FNA
  929. X    bind-to-key execute-macro-2    FNB
  930. X    bind-to-key execute-macro-10    FNC
  931. X    bind-to-key exit-emacs        FND
  932. X    clear-message-line
  933. X!endm
  934. X
  935. X;    and bring that menu up
  936. X
  937. X    execute-macro-1
  938. X    write-message "         [loading MENU system]"
  939. X
  940. X;    set up the editor control menu
  941. X
  942. X2    store-macro
  943. X    save-window
  944. X    1 next-window
  945. X    beginning-of-file
  946. X    search-forward "<<02"
  947. X    next-line
  948. X    1 redraw-display
  949. X    restore-window
  950. X    update-screen
  951. X
  952. X;    ***** Rebind the Function key group
  953. X
  954. X    bind-to-key execute-macro-11    FN;
  955. X    bind-to-key execute-macro-12    FN<
  956. X    bind-to-key execute-macro-13    FN=
  957. X    bind-to-key execute-macro-14    FN>
  958. X    bind-to-key execute-macro-15    FN?
  959. X    bind-to-key execute-macro-16    FN@
  960. X    bind-to-key execute-macro-17    FNA
  961. X    bind-to-key execute-macro-18    FNB
  962. X    bind-to-key execute-macro-19    FNC
  963. X    bind-to-key execute-macro-1    FND
  964. X    clear-message-line
  965. X!endm
  966. X
  967. X;    Activate word case/screen control Menu
  968. X
  969. X3    store-macro
  970. X    save-window
  971. X    1 next-window
  972. X    beginning-of-file
  973. X    search-forward "<<03"
  974. X    next-line
  975. X    1 redraw-display
  976. X    restore-window
  977. X    update-screen
  978. X
  979. X;    ***** Rebind the Function key group
  980. X
  981. X    bind-to-key case-word-upper    FN;
  982. X    bind-to-key case-region-upper    FN<
  983. X    bind-to-key case-word-lower    FN=
  984. X    bind-to-key case-region-lower    FN>
  985. X    bind-to-key case-word-capitalize FN?
  986. X    unbind-key FN@
  987. X    bind-to-key clear-and-redraw    FNA
  988. X    bind-to-key set-mark        FNB
  989. X    bind-to-key redraw-display    FNC
  990. X    bind-to-key execute-macro-1    FND
  991. X    clear-message-line
  992. X!endm
  993. X
  994. X;    Activate paging/scrolling Menu
  995. X
  996. X4    store-macro
  997. X    save-window
  998. X    1 next-window
  999. X    beginning-of-file
  1000. X    search-forward "<<08"
  1001. X    next-line
  1002. X    1 redraw-display
  1003. X    restore-window
  1004. X    update-screen
  1005. X
  1006. X;    ***** Rebind the Function key group
  1007. X
  1008. X    bind-to-key previous-page    FN;
  1009. X    bind-to-key next-page        FN<
  1010. X    bind-to-key move-window-down    FN=
  1011. X    bind-to-key move-window-up    FN>
  1012. X    bind-to-key scroll-next-up    FN?
  1013. X    unbind-key             FN@
  1014. X    bind-to-key scroll-next-down    FNA
  1015. X    unbind-key             FNB
  1016. X    bind-to-key exchange-point-and-mark FNC
  1017. X    bind-to-key execute-macro-1    FND
  1018. X    clear-message-line
  1019. X!endm
  1020. X
  1021. X;    Activate cut & paste Menu
  1022. X
  1023. X5    store-macro
  1024. X    save-window
  1025. X    1 next-window
  1026. X    beginning-of-file
  1027. X    search-forward "<<04"
  1028. X    next-line
  1029. X    1 redraw-display
  1030. X    restore-window
  1031. X    update-screen
  1032. X
  1033. X;    ***** Rebind the Function key group
  1034. X
  1035. X    bind-to-key set-mark        FN;
  1036. X    unbind-key FN<
  1037. X    bind-to-key kill-region        FN=
  1038. X    unbind-key FN>
  1039. X    bind-to-key copy-region        FN?
  1040. X    unbind-key FN@
  1041. X    bind-to-key yank        FNA
  1042. X    unbind-key FNB
  1043. X    unbind-key FNC
  1044. X    bind-to-key execute-macro-1    FND
  1045. X    clear-message-line
  1046. X!endm
  1047. X
  1048. X;    Activate Search & replace Menu
  1049. X
  1050. X6    store-macro
  1051. X    save-window
  1052. X    1 next-window
  1053. X    beginning-of-file
  1054. X    search-forward "<<09"
  1055. X    next-line
  1056. X    1 redraw-display
  1057. X    restore-window
  1058. X    update-screen
  1059. X
  1060. X;    ***** Rebind the Function key group
  1061. X
  1062. X    bind-to-key search-forward    FN;
  1063. X    bind-to-key search-reverse    FN<
  1064. X    bind-to-key hunt-forward    FN=
  1065. X    bind-to-key hunt-backward    FN>
  1066. X    bind-to-key incremental-search    FN?
  1067. X    bind-to-key reverse-incremental-search FN@
  1068. X    bind-to-key replace-string    FNA
  1069. X    bind-to-key query-replace-string FNB
  1070. X    unbind-key FNC
  1071. X    bind-to-key execute-macro-1    FND
  1072. X    clear-message-line
  1073. X!endm
  1074. X
  1075. X;    Activate Deletion Menu
  1076. X
  1077. X7    store-macro
  1078. X    save-window
  1079. X    1 next-window
  1080. X    beginning-of-file
  1081. X    search-forward "<<05"
  1082. X    next-line
  1083. X    1 redraw-display
  1084. X    restore-window
  1085. X    update-screen
  1086. X
  1087. X;    ***** Rebind the Function key group
  1088. X
  1089. X    bind-to-key delete-previous-character FN;
  1090. X    unbind-key FN<
  1091. X    bind-to-key delete-next-character FN=
  1092. X    unbind-key FN>
  1093. X    bind-to-key kill-to-end-of-line    FN?
  1094. X    unbind-key FN@
  1095. X    bind-to-key delete-blank-lines    FNA
  1096. X    unbind-key FNB
  1097. X    unbind-key FNC
  1098. X    bind-to-key execute-macro-1    FND
  1099. X    clear-message-line
  1100. X!endm
  1101. X
  1102. X;    Activate Word procesing Menu
  1103. X
  1104. X8    store-macro
  1105. X    save-window
  1106. X    1 next-window
  1107. X    beginning-of-file
  1108. X    search-forward "<<10"
  1109. X    next-line
  1110. X    1 redraw-display
  1111. X    restore-window
  1112. X    update-screen
  1113. X
  1114. X;    ***** Rebind the Function key group
  1115. X
  1116. X    bind-to-key previous-word    FN;
  1117. X    bind-to-key next-word        FN<
  1118. X    bind-to-key previous-paragraph    FN=
  1119. X    bind-to-key next-paragraph    FN>
  1120. X    bind-to-key fill-paragraph    FN?
  1121. X    bind-to-key kill-paragraph    FN@
  1122. X    bind-to-key delete-previous-word FNA
  1123. X    bind-to-key delete-next-word    FNB
  1124. X    bind-to-key count-words        FNC
  1125. X    bind-to-key execute-macro-1    FND
  1126. X    clear-message-line
  1127. X!endm
  1128. X
  1129. X;    Activate Insertion Menu
  1130. X
  1131. X9    store-macro
  1132. X    save-window
  1133. X    1 next-window
  1134. X    beginning-of-file
  1135. X    search-forward "<<06"
  1136. X    next-line
  1137. X    1 redraw-display
  1138. X    restore-window
  1139. X    update-screen
  1140. X
  1141. X;    ***** Rebind the Function key group
  1142. X
  1143. X    bind-to-key open-line        FN;
  1144. X    bind-to-key insert-string    FN<
  1145. X    bind-to-key handle-tab        FN=
  1146. X    bind-to-key quote-character    FN>
  1147. X    bind-to-key insert-space    FN?
  1148. X    bind-to-key transpose-characters FN@
  1149. X    bind-to-key newline-and-indent    FNA
  1150. X    unbind-key FNB
  1151. X    bind-to-key newline        FNC
  1152. X    bind-to-key execute-macro-1    FND
  1153. X    clear-message-line
  1154. X!endm
  1155. X
  1156. X;    Activate Cursor movement Menu
  1157. X
  1158. X10    store-macro
  1159. X    save-window
  1160. X    1 next-window
  1161. X    beginning-of-file
  1162. X    search-forward "<<07"
  1163. X    next-line
  1164. X    1 redraw-display
  1165. X    restore-window
  1166. X    update-screen
  1167. X
  1168. X;    ***** Rebind the Function key group
  1169. X
  1170. X    bind-to-key beginning-of-file    FN;
  1171. X    bind-to-key previous-line    FN<
  1172. X    bind-to-key backward-character    FN=
  1173. X    bind-to-key forward-character    FN>
  1174. X    bind-to-key end-of-file        FN?
  1175. X    bind-to-key next-line        FN@
  1176. X    bind-to-key beginning-of-line    FNA
  1177. X    bind-to-key end-of-line        FNB
  1178. X    bind-to-key execute-macro-21    FNC
  1179. X    bind-to-key execute-macro-1    FND
  1180. X    clear-message-line
  1181. X!endm
  1182. X
  1183. X21    store-macro
  1184. X    @"Line number to go to: " goto-line
  1185. X!endm
  1186. X
  1187. X;    Activate Buffer Menu
  1188. X
  1189. X11    store-macro
  1190. X    save-window
  1191. X    1 next-window
  1192. X    beginning-of-file
  1193. X    search-forward "<<11"
  1194. X    next-line
  1195. X    1 redraw-display
  1196. X    restore-window
  1197. X    update-screen
  1198. X
  1199. X;    ***** Rebind the Function key group
  1200. X
  1201. X    bind-to-key buffer-position    FN;
  1202. X    bind-to-key unmark-buffer    FN<
  1203. X    bind-to-key delete-buffer    FN=
  1204. X    bind-to-key next-buffer        FN>
  1205. X    bind-to-key list-buffers    FN?
  1206. X    bind-to-key execute-macro-22    FN@
  1207. X    bind-to-key name-buffer        FNA
  1208. X    unbind-key FNB
  1209. X    bind-to-key select-buffer    FNC
  1210. X    bind-to-key execute-macro-2    FND
  1211. X    clear-message-line
  1212. X!endm
  1213. X
  1214. X22    store-macro
  1215. X    filter-buffer @"Name of DOS filter: "
  1216. X!endm
  1217. X;    Macro Menu
  1218. X
  1219. X12    store-macro
  1220. X    save-window
  1221. X    1 next-window
  1222. X    beginning-of-file
  1223. X    search-forward "<<11"
  1224. X    next-line
  1225. X    1 redraw-display
  1226. X    restore-window
  1227. X    update-screen
  1228. X
  1229. X;    ***** Rebind the Function key group
  1230. X
  1231. X    bind-to-key begin-macro        FN;
  1232. X    unbind-key FN<
  1233. X    bind-to-key end-macro        FN=
  1234. X    unbind-key FN>
  1235. X    bind-to-key execute-macro    FN?
  1236. X    unbind-key FN@
  1237. X    unbind-key FNA
  1238. X    unbind-key FNB
  1239. X    unbind-key FNC
  1240. X    bind-to-key execute-macro-2    FND
  1241. X    clear-message-line
  1242. X!endm
  1243. X
  1244. X;    Color change Menu
  1245. X
  1246. X13    store-macro
  1247. X    save-window
  1248. X    1 next-window
  1249. X    beginning-of-file
  1250. X    search-forward "<<12"
  1251. X    next-line
  1252. X    1 redraw-display
  1253. X    restore-window
  1254. X    update-screen
  1255. X
  1256. X;    ***** Rebind the Function key group
  1257. X
  1258. X    bind-to-key execute-macro-23    FN;
  1259. X    unbind-key FN<
  1260. X    bind-to-key execute-macro-24    FN=
  1261. X    unbind-key FN>
  1262. X    bind-to-key execute-macro-25    FN?
  1263. X    unbind-key FN@
  1264. X    bind-to-key execute-macro-26    FNA
  1265. X    unbind-key FNB
  1266. X    unbind-key FNC
  1267. X    bind-to-key execute-macro-2    FND
  1268. X    clear-message-line
  1269. X!endm
  1270. X
  1271. X;    Set forground color
  1272. X
  1273. X23    store-macro
  1274. X    save-window
  1275. X    1 next-window
  1276. X    select-buffer "[color]"
  1277. X    beginning-of-file
  1278. X    insert-string @"Color to change to: "
  1279. X    newline
  1280. X    beginning-of-file
  1281. X    case-word-upper
  1282. X    beginning-of-file
  1283. X    unmark-buffer
  1284. X    select-buffer "menu window"
  1285. X    1 redraw-display
  1286. X    restore-window
  1287. X    add-mode #"[color]"
  1288. X    delete-buffer "[color]"
  1289. X!endm
  1290. X
  1291. X;    Set background color
  1292. X
  1293. X24    store-macro
  1294. X    save-window
  1295. X    1 next-window
  1296. X    select-buffer "[color]"
  1297. X    beginning-of-file
  1298. X    insert-string @"Color to change to: "
  1299. X    newline
  1300. X    beginning-of-file
  1301. X    case-word-lower
  1302. X    beginning-of-file
  1303. X    unmark-buffer
  1304. X    select-buffer "menu window"
  1305. X    1 redraw-display
  1306. X    restore-window
  1307. X    add-mode #"[color]"
  1308. X    delete-buffer "[color]"
  1309. X!endm
  1310. X
  1311. X;    Set global forground color
  1312. X
  1313. X25    store-macro
  1314. X    save-window
  1315. X    1 next-window
  1316. X    select-buffer "[color]"
  1317. X    beginning-of-file
  1318. X    insert-string @"Color to change to: "
  1319. X    newline
  1320. X    beginning-of-file
  1321. X    case-word-upper
  1322. X    beginning-of-file
  1323. X    unmark-buffer
  1324. X    select-buffer "menu window"
  1325. X    1 redraw-display
  1326. X    restore-window
  1327. X    add-global-mode #"[color]"
  1328. X    delete-buffer "[color]"
  1329. X!endm
  1330. X
  1331. X;    Set global background color
  1332. X
  1333. X26    store-macro
  1334. X    save-window
  1335. X    1 next-window
  1336. X    select-buffer "[color]"
  1337. X    beginning-of-file
  1338. X    insert-string @"Color to change to: "
  1339. X    newline
  1340. X    beginning-of-file
  1341. X    case-word-lower
  1342. X    beginning-of-file
  1343. X    unmark-buffer
  1344. X    select-buffer "menu window"
  1345. X    1 redraw-display
  1346. X    restore-window
  1347. X    add-global-mode #"[color]"
  1348. X    delete-buffer "[color]"
  1349. X!endm
  1350. X
  1351. X;    set Mode Menu
  1352. X
  1353. X14    store-macro
  1354. X    save-window
  1355. X    1 next-window
  1356. X    beginning-of-file
  1357. X    search-forward "<<17"
  1358. X    next-line
  1359. X    1 redraw-display
  1360. X    restore-window
  1361. X    update-screen
  1362. X
  1363. X;    ***** Rebind the Function key group
  1364. X
  1365. X    bind-to-key add-mode        FN;
  1366. X    bind-to-key add-global-mode    FN<
  1367. X    bind-to-key delete-mode        FN=
  1368. X    bind-to-key delete-global-mode    FN>
  1369. X    unbind-key FN?
  1370. X    bind-to-key execute-macro-27    FN@
  1371. X    unbind-key FNA
  1372. X    unbind-key FNB
  1373. X    bind-to-key select-buffer    FNC
  1374. X    bind-to-key execute-macro-2    FND
  1375. X    clear-message-line
  1376. X!endm
  1377. X
  1378. X27    store-macro
  1379. X    @"Column to fill to: " set-fill-column
  1380. X!endm
  1381. X
  1382. X;    DOS command Menu
  1383. X
  1384. X15    store-macro
  1385. X    save-window
  1386. X    1 next-window
  1387. X    beginning-of-file
  1388. X    search-forward "<<13"
  1389. X    next-line
  1390. X    1 redraw-display
  1391. X    restore-window
  1392. X    update-screen
  1393. X
  1394. X;    ***** Rebind the Function key group
  1395. X
  1396. X    bind-to-key shell-command    FN;
  1397. X    unbind-key FN<
  1398. X    bind-to-key pipe-command    FN=
  1399. X    unbind-key FN>
  1400. X    bind-to-key i-shell        FN?
  1401. X    unbind-key FN@
  1402. X    bind-to-key quick-exit        FNA
  1403. X    unbind-key FNB
  1404. X    bind-to-key exit-emacs        FNC
  1405. X    bind-to-key execute-macro-2    FND
  1406. X    clear-message-line
  1407. X!endm
  1408. X
  1409. X;    Script Menu
  1410. X
  1411. X16    store-macro
  1412. X    save-window
  1413. X    1 next-window
  1414. X    beginning-of-file
  1415. X    search-forward "<<18"
  1416. X    next-line
  1417. X    1 redraw-display
  1418. X    restore-window
  1419. X    update-screen
  1420. X
  1421. X;    ***** Rebind the Function key group
  1422. X
  1423. X    bind-to-key execute-file    FN;
  1424. X    bind-to-key execute-command-line FN<
  1425. X    bind-to-key execute-buffer    FN=
  1426. X    bind-to-key execute-named-command FN>
  1427. X    unbind-key FN?
  1428. X    unbind-key FN@
  1429. X    unbind-key FNA
  1430. X    unbind-key FNB
  1431. X    unbind-key FNC
  1432. X    bind-to-key execute-macro-2    FND
  1433. X    clear-message-line
  1434. X!endm
  1435. X
  1436. X;    File access Menu
  1437. X
  1438. X17    store-macro
  1439. X    save-window
  1440. X    1 next-window
  1441. X    beginning-of-file
  1442. X    search-forward "<<14"
  1443. X    next-line
  1444. X    1 redraw-display
  1445. X    restore-window
  1446. X    update-screen
  1447. X
  1448. X;    ***** Rebind the Function key group
  1449. X
  1450. X    bind-to-key find-file        FN;
  1451. X    bind-to-key save-file        FN<
  1452. X    bind-to-key view-file        FN=
  1453. X    bind-to-key write-file        FN>
  1454. X    bind-to-key read-file        FN?
  1455. X    bind-to-key change-file-name    FN@
  1456. X    bind-to-key insert-file        FNA
  1457. X    unbind-key FNB
  1458. X    unbind-key FNC
  1459. X    bind-to-key execute-macro-2    FND
  1460. X    clear-message-line
  1461. X!endm
  1462. X
  1463. X;    Window Menu
  1464. X
  1465. X18    store-macro
  1466. X    save-window
  1467. X    1 next-window
  1468. X    beginning-of-file
  1469. X    search-forward "<<19"
  1470. X    next-line
  1471. X    1 redraw-display
  1472. X    restore-window
  1473. X    update-screen
  1474. X
  1475. X;    ***** Rebind the Function key group
  1476. X
  1477. X    bind-to-key split-current-window FN;
  1478. X    bind-to-key delete-other-windows FN<
  1479. X    bind-to-key resize-window    FN=
  1480. X    bind-to-key delete-window    FN>
  1481. X    bind-to-key shrink-window    FN?
  1482. X    bind-to-key grow-window        FN@
  1483. X    bind-to-key next-window        FNA
  1484. X    bind-to-key previous-window    FNB
  1485. X    unbind-key FNC
  1486. X    bind-to-key execute-macro-2    FND
  1487. X    clear-message-line
  1488. X!endm
  1489. X
  1490. X;    key binding Menu
  1491. X
  1492. X19    store-macro
  1493. X    save-window
  1494. X    1 next-window
  1495. X    beginning-of-file
  1496. X    search-forward "<<15"
  1497. X    next-line
  1498. X    1 redraw-display
  1499. X    restore-window
  1500. X    update-screen
  1501. X
  1502. X;    ***** Rebind the Function key group
  1503. X
  1504. X    bind-to-key bind-to-key        FN;
  1505. X    unbind-key FN<
  1506. X    bind-to-key unbind-key        FN=
  1507. X    unbind-key FN>
  1508. X    bind-to-key describe-key    FN?
  1509. X    unbind-key FN@
  1510. X    bind-to-key describe-bindings    FNA
  1511. X    unbind-key FNB
  1512. X    unbind-key FNC
  1513. X    bind-to-key execute-macro-2    FND
  1514. X    clear-message-line
  1515. X!endm
  1516. X
  1517. X    clear-message-line
  1518. END_OF_menu.cmd
  1519. if test 11966 -ne `wc -c <menu.cmd`; then
  1520.     echo shar: \"menu.cmd\" unpacked with wrong size!
  1521. fi
  1522. # end of overwriting check
  1523. fi
  1524. echo shar: Extracting \"st520.c\" \(10316 characters\)
  1525. if test -f st520.c ; then 
  1526.   echo shar: Will not over-write existing file \"st520.c\"
  1527. else
  1528. sed "s/^X//" >st520.c <<'END_OF_st520.c'
  1529. X/*
  1530. X
  1531. XThe routines in this file provide support for the Atari ST520 or 1040
  1532. Xusing VT52 emulation.  The I/O services are provided by routines in
  1533. X"termio.c".  It compiles into nothing if not a ST520 style device.  The
  1534. Xbell on the ST520 is terrible, so the "beep" routine is conditionalized
  1535. Xon defining BEL. 
  1536. X
  1537. X*/
  1538. X
  1539. X#define    termdef    1            /* don't define "term" external */
  1540. X
  1541. X#include        <stdio.h>
  1542. X#include        "estruct.h"
  1543. X#include    "edef.h"
  1544. X
  1545. X#if MEGAMAX
  1546. Xoverlay "st520"
  1547. X#endif
  1548. X
  1549. X#if     ATARI & ST520 & MEGAMAX
  1550. X#include    <osbind.h>
  1551. X#include    <ctype.h>
  1552. X
  1553. X#define LINEA_INIT 0xA000
  1554. X#define V_CEL_WR   -0x28
  1555. X#define V_CEL_MY   -0x2a
  1556. X#define V_CEL_HT   -0x2e
  1557. X#define V_FNT_AD   -0x16
  1558. X#define V_OFF_AD   -0x0a
  1559. X#define V_DISAB    -346
  1560. X
  1561. X#define NROW    24                      /* Screen size.                 */
  1562. X#define NCOL    80                      /* Edit if you want to.         */
  1563. X#define    MARGIN    8            /* size of minimim margin and    */
  1564. X#define    SCRSIZ    64            /* scroll size for extended lines */
  1565. X#define    NPAUSE    25            /* # times thru update to pause */
  1566. X#define BIAS    0x20                    /* Origin 0 coordinate bias.    */
  1567. X#define ESC     0x1B                    /* ESC character.               */
  1568. X#define BEL     0x07                    /* ascii bell character         */
  1569. X
  1570. Xextern  int     ttopen();               /* Forward references.          */
  1571. Xextern  int     ttgetc();
  1572. Xextern  int     ttputc();
  1573. Xextern  int     ttflush();
  1574. Xextern  int     ttclose();
  1575. Xextern  int     st520move();
  1576. Xextern  int     st520eeol();
  1577. Xextern  int     st520eeop();
  1578. Xextern  int     st520beep();
  1579. Xextern  int     st520open();
  1580. Xextern    int    st520close();
  1581. Xextern    int    st520rev();
  1582. Xextern    int    st520cres();
  1583. Xextern  int st520kopen();
  1584. Xextern  int st520kclose();
  1585. X
  1586. X#if    COLOR
  1587. Xextern    int    st520fcol();
  1588. Xextern    int    st520bcol();
  1589. X
  1590. Xint        cfcolor = -1;        /* current fg (character) color */
  1591. Xint        cbcolor = -1;        /* current bg color */
  1592. Xint        oldpal[8];        /* pallette when emacs was invoked */
  1593. Xint        newpal[8] = {        /* default emacs pallette */
  1594. X    0x000, 0x700, 0x070, 0x770, 0x007, 0x707, 0x077, 0x777};
  1595. X#endif
  1596. X
  1597. Xint STncolors = 0;        /* number of colors  */
  1598. Xint STrez;            /* physical screen resolution */    
  1599. X
  1600. X/*
  1601. X * Dispatch table. All the
  1602. X * hard fields just point into the
  1603. X * terminal I/O code.
  1604. X */
  1605. XTERM    term    = {
  1606. X        NROW-1,
  1607. X        NCOL,
  1608. X    MARGIN,
  1609. X    MARGIN,
  1610. X    SCRSIZ,
  1611. X    NPAUSE,
  1612. X        &st520open,
  1613. X        &st520close,
  1614. X    &st520kopen,
  1615. X    &st520kclose,
  1616. X        &ttgetc,
  1617. X        &ttputc,
  1618. X        &ttflush,
  1619. X        &st520move,
  1620. X        &st520eeol,
  1621. X        &st520eeop,
  1622. X        &st520beep,
  1623. X        &st520rev,
  1624. X        &st520cres
  1625. X#if    COLOR
  1626. X    , &st520fcol,
  1627. X    &st520bcol
  1628. X#endif
  1629. X};
  1630. X    struct KBDvecs {
  1631. X        int (*midivec) ();
  1632. X        int (*vkbderr) ();
  1633. X        int (*vmiderr) ();
  1634. X        int (*statvec) ();
  1635. X        int (*mousevec) ();
  1636. X        int (*clockvec) ();
  1637. X        int (*joyvec) ();
  1638. X        int (*midisys) ();
  1639. X        int (*ikbdsys) ();
  1640. X    };
  1641. X    struct Param {
  1642. X        char topmode;
  1643. X        char buttons;
  1644. X        char xparam;
  1645. X        char yparam;
  1646. X        int xmax,ymax;
  1647. X        int xinitial,yinitial;
  1648. X    };
  1649. X    struct KBDvecs *kbdvecs;
  1650. X    struct Param *paramp;
  1651. X    char kbdcmds[25];
  1652. X
  1653. Xst520move(row, col)
  1654. X{
  1655. X        ttputc(ESC);
  1656. X        ttputc('Y');
  1657. X        ttputc(row+BIAS);
  1658. X        ttputc(col+BIAS);
  1659. X}
  1660. X
  1661. Xst520eeol()
  1662. X{
  1663. X        ttputc(ESC);
  1664. X        ttputc('K');
  1665. X}
  1666. X
  1667. Xst520eeop()
  1668. X{
  1669. X
  1670. X#if    COLOR
  1671. X        st520fcol(gfcolor);
  1672. X        st520bcol(gbcolor);
  1673. X#endif
  1674. X        ttputc(ESC);
  1675. X        ttputc('J');
  1676. X}
  1677. X
  1678. Xst520rev(status)    /* set the reverse video state */
  1679. X
  1680. Xint status;    /* TRUE = reverse video, FALSE = normal video */
  1681. X
  1682. X{
  1683. X
  1684. X    if(status) {
  1685. X        ttputc(ESC);
  1686. X        ttputc('p');
  1687. X    }
  1688. X    else {
  1689. X        ttputc(ESC);
  1690. X        ttputc('q');
  1691. X    }
  1692. X}
  1693. X
  1694. X#if    COLOR
  1695. Xst520fcol(color)
  1696. Xint color;    
  1697. X{
  1698. X        if(color == cfcolor || !STncolors)
  1699. X            return;
  1700. X        else {
  1701. X
  1702. X            ttputc(ESC);
  1703. X            ttputc('b');
  1704. X            ttputc(color & 0x0f);
  1705. X            cfcolor = color;
  1706. X        }
  1707. X}
  1708. X
  1709. Xst520bcol(color)
  1710. Xint color;
  1711. X{
  1712. X        if(color == cbcolor || !STncolors)
  1713. X            return;
  1714. X        else {
  1715. X            ttputc(ESC);
  1716. X            ttputc('c');
  1717. X            ttputc(color & 0x0f);
  1718. X            cbcolor = color;
  1719. X        }
  1720. X
  1721. X}
  1722. X#endif
  1723. X
  1724. Xst520beep()
  1725. X{
  1726. X#ifdef  BEL
  1727. X        ttputc(BEL);
  1728. X        ttflush();
  1729. X#endif
  1730. X}
  1731. X
  1732. Xst520open()
  1733. X{
  1734. X    int i,j,k;
  1735. X    long phys, log;    /* screen bases */
  1736. X    
  1737. X/* IMPORTANT: it is ABSOLUTELY necessary that the default resolution be the
  1738. X *    largest possible so that display will allocate (malloc) the maximum
  1739. X *    size for the VIDEO arrray
  1740. X */
  1741. X    STrez = Getrez();
  1742. X    switch(STrez) {
  1743. X        case 0: /* low res 25x40 16 colors */
  1744. X            strcpy(sres, "LOW");
  1745. X            phys = Physbase();
  1746. X            log  = Logbase();
  1747. X            Setscreen(log, phys, 1);
  1748. X            STrez = 1;
  1749. X            /* fall thru to med res */
  1750. X
  1751. X        case 1: /* med res 25x80 4 colors */
  1752. X            if (STrez == 1) strcpy(sres, "MEDIUM");
  1753. X            term.t_nrow = 25 - 1;
  1754. X            term.t_ncol  = 80;
  1755. X            grez = 1;
  1756. X#if    COLOR
  1757. X            STncolors = 4;
  1758. X            for(i=0;i<8;i++) {
  1759. X                oldpal[i] = Setcolor(i,newpal[i]);
  1760. X            }
  1761. X#endif
  1762. X            break;
  1763. X        case 2: /* high res 25x80 no colors */
  1764. X            strcpy(sres, "HIGH");
  1765. X            term.t_nrow  = 40 - 1;
  1766. X            term.t_ncol  = 80;
  1767. X            grez = 2;
  1768. X            make_8x10(); /* create a smaller font */
  1769. X            set_40();    /* and go to 40 line mode */
  1770. X#if    COLOR
  1771. X            STncolors = 0;
  1772. X#endif
  1773. X            break;
  1774. X    }
  1775. X
  1776. X    revexist = TRUE;
  1777. X    eolexist = TRUE;
  1778. X    paramp = (struct Param *)malloc(sizeof(struct Param));
  1779. X    kbdvecs = (struct KBDvecs *)Kbdvbase();
  1780. X    paramp -> topmode = 0;
  1781. X    paramp -> buttons = 4;
  1782. X    paramp -> xparam = 8;
  1783. X    paramp -> yparam = 10;
  1784. X    paramp -> xmax = 79;
  1785. X    paramp -> ymax = 23;
  1786. X    paramp -> xinitial = 0;
  1787. X    paramp -> yinitial = 0;
  1788. X    Initmous(1,paramp,kbdvecs -> mousevec);
  1789. X
  1790. X    i = 0;
  1791. X    kbdcmds[i++] = 0x0a;    /*set mouse keycode mode */
  1792. X    kbdcmds[i++] = 0x08;
  1793. X    kbdcmds[i++] = 0x0a;
  1794. X    Ikbdws(i-1,&kbdcmds[0]);
  1795. X    Cursconf(1,0);
  1796. X    Cursconf(3,0);
  1797. X    Cconout(27);Cconout('E');
  1798. X        ttopen();
  1799. X}
  1800. X
  1801. Xst520close()
  1802. X
  1803. X{
  1804. X    int i,j,k;
  1805. X
  1806. X    i = 0;
  1807. X    kbdcmds[i++] = 0x80;    /*reset mouse keycode mode */
  1808. X    kbdcmds[i++] = 0x01;
  1809. X    Ikbdws(i-1,&kbdcmds[0]);
  1810. X    if(grez == 2 && STrez == 2) /* b/w monitor in 40 row mode */
  1811. X        restore();
  1812. X
  1813. X#if        COLOR
  1814. X    for(i=0;i<STncolors;i++)
  1815. X        Setcolor(i,oldpal[i]);
  1816. X#endif
  1817. X    Cconout(27);Cconout('E');
  1818. X    paramp -> buttons = 0;
  1819. X    Initmous(2,paramp,kbdvecs -> mousevec);
  1820. X    i = 0;
  1821. X    kbdcmds[i++] = 0x80;    /*reset the keyboard*/
  1822. X    kbdcmds[i++] = 0x01;
  1823. X    Ikbdws(i-1,&kbdcmds[0]);
  1824. X    Cursconf(1,0);
  1825. X    ttclose();
  1826. X}
  1827. Xst520kopen()
  1828. X{
  1829. X
  1830. X}
  1831. Xst520kclose()
  1832. X{
  1833. X
  1834. X}
  1835. X
  1836. Xst520cres(res)        /* change screen resolution */
  1837. X
  1838. Xchar *res;        /* resolution to change to */
  1839. X
  1840. X{
  1841. X    register int nurez;    /* number of res to change to */
  1842. X    int ierr, i, j ,k;
  1843. X    long phys, log;    /* screen bases */
  1844. X    char dum[80]; /* for debugging only */
  1845. X
  1846. X    /* determine the needed resolution */
  1847. X    if (strcmp(res, "LOW") == 0)
  1848. X        nurez = 1;
  1849. X    else if (strcmp(res, "MEDIUM") == 0)
  1850. X        nurez = 2;
  1851. X    else if (strcmp(res, "HIGH") == 0)
  1852. X        nurez = 3;
  1853. X    else
  1854. X        return(FALSE);
  1855. X
  1856. X    if(grez == nurez)
  1857. X        return(TRUE);
  1858. X        
  1859. X    if(STrez == 2) { /* b/w monitor-only allow hi | med rez */
  1860. X        switch(nurez) {
  1861. X            case 2: /* high res */
  1862. X                term.t_nrow  = 40 - 1;
  1863. X                term.t_ncol  = 80;
  1864. X                make_8x10(); /* create a smaller font */
  1865. X                set_40();    /* and go to 40 line mode */
  1866. X                grez = 2;
  1867. X                sgarbf = TRUE;
  1868. X                onlywind(1,1);
  1869. X                strcpy(sres, "HIGH");
  1870. X                break;
  1871. X            case 1: /* med res */
  1872. X                term.t_nrow  = 25 - 1;
  1873. X                term.t_ncol  = 80;
  1874. X                restore();
  1875. X                grez = 1;
  1876. X                sgarbf = TRUE;
  1877. X                onlywind(1,1);
  1878. X                strcpy(sres, "MEDIUM");
  1879. X                break;
  1880. X            default:
  1881. X                mlwrite("Invalid resolution");
  1882. X                return(FALSE);
  1883. X                break;
  1884. X        }
  1885. X    }
  1886. X    else { /* color monitor-only allow low | medium resolution */
  1887. X        phys = Physbase();
  1888. X        log  = Logbase();
  1889. X        switch(nurez) {
  1890. X            case 1:
  1891. X                term.t_nrow  = 25 - 1;
  1892. X                term.t_ncol  = 80;
  1893. X                Setscreen(log, phys, 1);
  1894. X                STncolors = 4;
  1895. X                grez = 1;
  1896. X                sgarbf = TRUE;
  1897. X                onlywind(1,1);
  1898. X                strcpy(sres, "LOW");
  1899. X                break;
  1900. X            case 0:
  1901. X                term.t_nrow  = 25 - 1;
  1902. X                term.t_ncol  = 40;
  1903. X                Setscreen(log, phys, 0);
  1904. X                STncolors = 8;
  1905. X                grez = 0;
  1906. X                sgarbf = TRUE;
  1907. X                onlywind(1,1);
  1908. X                strcpy(sres, "MEDIUM");
  1909. X                break;
  1910. X            default:
  1911. X                mlwrite("%Invalid resolution");
  1912. X                return(FALSE);
  1913. X                break;
  1914. X        }
  1915. X    }
  1916. X    return(TRUE);
  1917. X}            
  1918. X
  1919. XSTcurblink(onoff)
  1920. Xint onoff;
  1921. X{
  1922. X    if(onoff)
  1923. X        Cursconf(2,0);
  1924. X    else
  1925. X        Cursconf(3,0);
  1926. X}
  1927. X
  1928. X
  1929. Xchar parm_save[28];
  1930. Xlong fnt_8x10[640];
  1931. X
  1932. Xmake_8x10()
  1933. X{
  1934. X    int i,j,k;
  1935. X    long savea23[2];
  1936. X    
  1937. X    for(i=0;i<640;i++)
  1938. X        fnt_8x10[i] = 0;
  1939. X        
  1940. X    asm {
  1941. X    movem.l    A2-A3,savea23(A6)
  1942. X    
  1943. X    dc.w    LINEA_INIT        ;A1 -> array of font headers
  1944. X
  1945. X    lea    parm_save(A4),A2    ;A2 -> parameters savearea
  1946. X    move.l    V_OFF_AD(A0),(A2)+
  1947. X    move.l    V_FNT_AD(A0),(A2)+
  1948. X    move.w    V_CEL_HT(A0),(A2)+
  1949. X    move.w    V_CEL_MY(A0),(A2)+
  1950. X    move.w    V_CEL_WR(A0),(A2)+
  1951. X
  1952. X
  1953. X    move.l    04(A1),A1        ; A1 -> 8x8 font header
  1954. X    move.l    76(A1),A2        ; A2 -> 8x8 font data
  1955. X    lea    fnt_8x10+0x100(A4),A3    ; A3 -> 2nd line of font buffer
  1956. X    move.w    #0x200-1,D0        ; D0 <- longword counter for font xfer
  1957. X
  1958. Xfnt_loop:
  1959. X
  1960. X    move.l    (A2)+,(A3)+
  1961. X    dbf    D0,fnt_loop
  1962. X        
  1963. X    movem.l    savea23(A6),A2-A3
  1964. X    }
  1965. X    
  1966. X}
  1967. X
  1968. Xset_40()
  1969. X{
  1970. X    long    savea23[2];
  1971. X    
  1972. X    asm {
  1973. X    
  1974. X;
  1975. X;  use the 8x10 character set: 40 line mode
  1976. X;
  1977. X
  1978. X    movem.l    A2-A3,savea23(A6)
  1979. X    
  1980. X    dc.w    LINEA_INIT
  1981. X
  1982. X    move.l    04(A1),A1        ; A1 -> 8x8 font header
  1983. X    move.l    72(A1),V_OFF_AD(A0)    ; v_off_ad <- 8x8  offset table addr
  1984. X    lea    fnt_8x10(A4),A2
  1985. X    move.l    A2,V_FNT_AD(A0)        ; v_fnt_ad <- 8x10 font data addr
  1986. X
  1987. X    move.w    #10,V_CEL_HT(A0)    ; v_cel_ht <- 10   8x10 cell height
  1988. X    move.w    #39,V_CEL_MY(A0)    ; v_cel_my <- 39   maximum cell "Y"
  1989. X    move.w    #800,V_CEL_WR(A0)    ; v_cel_wr <- 800  offset to cell Y+1
  1990. X
  1991. X    movem.l savea23,A2-A3
  1992. X    }
  1993. X}
  1994. X
  1995. Xset_20()
  1996. X{
  1997. X    long    savea23[2];
  1998. X
  1999. X    asm {
  2000. X        
  2001. X;
  2002. X;  use the 8x10 character set: 20 line mode
  2003. X;
  2004. X
  2005. X    movem.l    A2-A3,savea23(A6)
  2006. X    
  2007. X    dc.w    LINEA_INIT        ; A0 -> line A variables
  2008. X
  2009. X    move.l    04(A1),A1        ; A1 -> 8x8 font header
  2010. X    move.l    72(A1),V_OFF_AD(A0)    ; v_off_ad <- 8x8  offset table addr
  2011. X    lea    fnt_8x10(A4),A2
  2012. X    move.l    A2,V_FNT_AD(A0)        ; v_fnt_ad <- 8x10 font data addr
  2013. X
  2014. X    move.w    #10,V_CEL_HT(A0)    ; v_cel_ht <- 10   8x10 cell height
  2015. X    move.w    #19,V_CEL_MY(A0)    ; v_cel_my <- 19   maximum cell "Y"
  2016. X    move.w    #1600,V_CEL_WR(A0)    ; v_cel_wr <- 800  offset to cell Y+1
  2017. X    
  2018. X    movem.l    savea23,A2-A3
  2019. X    }
  2020. X}
  2021. X
  2022. X
  2023. Xrestore()
  2024. X{
  2025. X    long savea23[2];
  2026. X    
  2027. X    asm {
  2028. X    
  2029. X;  return what was saved in parameter save zone    
  2030. X
  2031. X    movem.l    A2-A3,savea23(A6)
  2032. X
  2033. X    dc.w    LINEA_INIT        ; a0 -> line A variables
  2034. X
  2035. X    lea    parm_save(A4),A2    ; a2 -> parameter save area
  2036. X    move.l    (A2)+,V_OFF_AD(A0)
  2037. X    move.l    (A2)+,V_FNT_AD(A0)
  2038. X    move.w    (A2)+,V_CEL_HT(A0)
  2039. X    move.w    (A2)+,V_CEL_MY(A0)
  2040. X    move.w    (A2)+,V_CEL_WR(A0)
  2041. X    
  2042. X    movem.l    savea23(A6),A2-A3
  2043. X    }          
  2044. X}
  2045. XGetCurStat(onoff)
  2046. Xint    onoff;
  2047. X{
  2048. X    long savea23[2];
  2049. X
  2050. X    asm {
  2051. X    movem.l    A2-A3,savea23(A6)
  2052. X
  2053. X    dc.w    LINEA_INIT        ; a0 -> line A variables
  2054. X    move.w    V_DISAB(A0),onoff(A6)    ; 0 = cursor visible
  2055. X    moveq    #0,D0
  2056. X    move.w    V_DISAB(A0),D0    
  2057. X    movem.l    savea23(A6),A2-A3
  2058. X    }          
  2059. X}
  2060. X#else
  2061. Xsthello()
  2062. X{
  2063. X}
  2064. X#endif
  2065. X
  2066. END_OF_st520.c
  2067. if test 10316 -ne `wc -c <st520.c`; then
  2068.     echo shar: \"st520.c\" unpacked with wrong size!
  2069. fi
  2070. # end of overwriting check
  2071. fi
  2072. echo shar: End of archive 4 \(of 14\).
  2073. cp /dev/null ark4isdone
  2074. MISSING=""
  2075. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do
  2076.     if test ! -f ark${I}isdone ; then
  2077.     MISSING="${MISSING} ${I}"
  2078.     fi
  2079. done
  2080. if test "${MISSING}" = "" ; then
  2081.     echo You have unpacked all 14 archives.
  2082.     echo "See the readme file"
  2083.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2084. else
  2085.     echo You still need to unpack the following archives:
  2086.     echo "        " ${MISSING}
  2087. fi
  2088. ##  End of shell archive.
  2089. exit 0
  2090.